/**
 * SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
 * SPDX-License-Identifier: Mulan PSL v2
 */

<template>
    <div class="operate-step-training__container">
        <div class="operate-step__list">
            <div v-for="(item,index) in operateList" 
                 :key="item.id"
                 class="operate-step__item"
                 :class="{'active':index===activeIndex-1}"
                 @click="_operatePreview (index)">
                <div class="operate__step">
                    Step {{ index+1 }}
                </div>
                <div class="operate__box">
                    <div class="operate-content">
                        <div class="operate__img"
                             :class="operateImg(item.img)"></div>
                        <div class="operate__name">
                            {{ item.name }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>

// import {isFunction} from 'src/util/typeof';

import {COMPONET_MARK} from 'src/home/mod_cluster/project_manager/feature_manager/const_data';
export default {
    name: 'OperateStep',
    props: {
        stepList:{
            default:()=>[],
            type:Array
        },

        //算子的active下标
        activeIndex:{
            default:0,
            type:Number
        }
    },

    data () {
        return {
            operateLayer: null,
            fieldList:[]
        };
    },

    computed: {
        operateList () {
            if (this.stepList.length) {
                let list = [];

                //只取后边几步第一步不要
                let stepList = this.stepList.slice(1);
                if (stepList.length > 0) {
                    stepList.forEach(item=>{
                        list.push(Object.assign({
                            formData:item.params
                        }, COMPONET_MARK[item.type]));
                    });
                }
                return list;
            }
            return [];
        }
    },
    methods: {
        operateImg (type) {
            return `img-${type}`;
        },

        //预览算子
        _operatePreview (index) {
            this.$emit('operate-preview', index + 1);
        }
    }
};
</script>

<style lang="less">
    .operate-step-training__container{
        padding-left: 8px;
        height: calc(100% - 65px);
        overflow: auto;
        .operate-step__list{
            height: 100%;
            overflow: auto;
        }
    .operate-step__item{
        width:182px;
        margin:10px auto;
        font-size: 14px;
        color: #14161A;
        margin-bottom: 20px;
        cursor: pointer;
        &.active{
            .operate__box{
                border: 2px solid #3366FF;
            }
        }
        .operate__step{
            margin-bottom: 8px;
            position: relative;
            padding-left: 5px;
            &:before{
                content: '';
                background: #204ED9;
                width: 4px;
                height: 4px;
                transform: rotate(45deg);
                position: absolute;
                left: -5px;
                top: 8px;
            }
        }
        .operate__box{
            width: 182px;
            height: 48px;
            margin: 0 auto;
            border: 1px solid #C8D0E0;
            border-radius: 2px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: #fff;
           
            .operate-content{
                margin-left: 12px;
                display: flex;
                align-items: center;
            }
          
        }
        .operate__img{
            width: 24px;
            height: 24px;
            margin-right: 4px;
            &.img-agg{
                background: url(../../../../img/agg.svg) no-repeat;
                background-size:100% 100%;
            }
            &.img-filter{
                background: url(../../../../img/filter.svg) no-repeat;
                background-size:100% 100%;
            }
            &.img-opr{
                background: url(../../../../img/opr.svg) no-repeat;
                background-size:100% 100%;
            }
            &.img-timeStamp{
                background: url(../../../../img/timeStamp.svg) no-repeat;
                background-size:100% 100%;
            }
            &.img-smooth{
                background: url(../../../../img/smooth.svg) no-repeat;
                background-size:100% 100%;
            }
            &.img-stringOpr{
                background: url(../../../../img/stringOpr.svg) no-repeat;
                background-size:100% 100%;
            }
            &.img-timeSeries{
                background: url(../../../../img/timeSeries.svg) no-repeat;
                background-size:100% 100%;
            }
            &.img-outlier{
                background: url(../../../../img/outlier.svg) no-repeat;
                background-size:100% 100%;
            }
        }
        
    }
    }
    
  
  
  
</style>


